package yuan.test;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.util.Properties;

public class DruidTest1 {
    public static void main(String[] args) throws Exception {
        //1通过prpoperties集合加载配置文件
        //通过druid连接池工厂获取连接池对象
        //通过连接池对象获取数据库连接进行操作
        InputStream is = DruidTest1.class.getClassLoader().getResourceAsStream("druid.properties");
        Properties prop=new Properties();
        prop.load(is);
        DataSource dataSource = DruidDataSourceFactory.createDataSource(prop);
        Connection connection = dataSource.getConnection();
        System.out.println(connection);

    }
}
